package com.example.haoyundaoyonghu.base;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;


import com.example.haoyundaoyonghu.dialog.ShowDialog;

import butterknife.ButterKnife;


public abstract class BasebFragment extends Fragment {

    public View rootView;
    public LayoutInflater mInflater;
    public Context mContext;

    private ShowDialog showDialog;



    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

    }

    @Nullable
   @Override
    public View onCreateView(@Nullable LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        if (rootView == null ){
            mInflater =inflater;
            mContext = inflater.getContext();
            rootView = mInflater.inflate(getRootViewId(),container,false);
            ButterKnife.bind(this,rootView);

            setInitView();
            initData();
        }
        return  rootView;
    }


    public abstract int getRootViewId();

    public abstract void setInitView();

    public void initData(){};




    /**
     * 通用消息
     * @param tit 标题
     * @param msg 消息
     * @param onClick  点击事件
     */
    public void setShowDialog(String tit,String msg,View.OnClickListener onClick){
        showDialog = new ShowDialog(mContext);
        showDialog.setShowDialog(tit,msg,onClick);
        showDialog.setCanceledOnTouchOutside(false);
        showDialog.show();
    }

}
